<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue 响应式原理</title>
</head>

<body>
    第一个：<div class="item1"></div>
    第二个；<div class="item2"></div>

    <script src="./index.js"></script>
    <script>
        let obj = {};
        this.ObserveAble(obj, 'name', 'key1', '.item1');
        this.ObserveAble(obj, 'age', 'key2', '.item2');

        obj.name = '章三'
        obj.age = '18'



        // Proxy的使用
        let obj2 = {
            name: 'werwer',
            age: 90
        }
        const proxy = new Proxy(obj2, {
            get(target, prop) {
                console.log(`调用get方法${prop}`);
                return target[prop];
            },
            set(target, prop, value) {
                console.log(`调用set方法${prop}`);
                target[prop] = value;
            },
            defineProperty(target,prop){
                console.log(`调用删除方法${prop}`);
                return delete target[prop];
            }
        })
    </script>
</body>

</html>